# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Eli Schwartz <eschwartz@archlinux.org>
# Contributor: Timothy Redaelli <timothy.redaelli@gmail.com>
# Contributor: carstene1ns <arch carsten-teibes de> - http://git.io/ctPKG
# Contributor: Jkkyll Wu <adaptee at gmail [dot] com>
# Contributor: Thomas Dziedzic < gostrc at gmail >
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>
# Contributor: Geoffroy Carrier <geoffroy.carrier@koon.fr>

pkgbase=qbittorrent
pkgname=(qbittorrent
         qbittorrent-nox)
pkgver=4.6.1
pkgrel=1
arch=(loong64 x86_64)
url='https://www.qbittorrent.org'
license=(custom GPL)
depends=(gcc-libs
         glibc
         libtorrent-rasterbar
         openssl
         qt6-base
         zlib)
makedepends=(boost
             cmake
             qt6-svg
             qt6-tools)
optdepends=('python: needed for torrent search tab')
source=(https://downloads.sourceforge.net/sourceforge/qbittorrent/${pkgname}-${pkgver}.tar.xz{,.asc})
sha256sums=('63223387cab9936a4feae21597b3631f20ba33f33fa73ef3f35d07d63cae3643'
            'SKIP')
validpgpkeys=('D8F3DA77AAC6741053599C136E4A2D025B7CC9A2') # sledgehammer999 <sledgehammer999@qbittorrent.org>

build() {
  cmake -B build -S $pkgbase-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DQT6=ON
  cmake --build build

  cmake -B build-nox -S $pkgbase-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DQT6=ON \
    -DGUI=OFF \
    -DSYSTEMD=ON
  cmake --build build-nox
}

package_qbittorrent() {
  pkgdesc='An advanced BitTorrent client programmed in C++, based on Qt toolkit and libtorrent-rasterbar'
  depends+=(qt6-svg hicolor-icon-theme)

  DESTDIR="$pkgdir" cmake --install build
  install -Dm644 $pkgbase-$pkgver/COPYING -t "$pkgdir"/usr/share/licenses/$pkgname
}

package_qbittorrent-nox() {
  pkgdesc='An advanced BitTorrent client programmed in C++, based on Qt toolkit and libtorrent-rasterbar, w/o gui'

  DESTDIR="$pkgdir" cmake --install build-nox
  install -Dm644 $pkgbase-$pkgver/COPYING -t "$pkgdir"/usr/share/licenses/$pkgname
}
